﻿using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Options;
using Microsoft.Extensions.Primitives;

using Utils.WeChat.Options;

namespace Microsoft.Extensions.DependencyInjection
{
    class WeChatConfigure : IConfigureOptions<WeChatOptions>
    {
        private readonly IConfiguration configuration;

        public WeChatConfigure(IConfiguration configuration)
        {
            this.configuration = configuration;
        }

        public void Configure(WeChatOptions options)
        { 
           configuration.Bind("WeChat", options);
            ChangeToken.OnChange(configuration.GetReloadToken, () =>
            {
                configuration.Bind("WeChat", options);
            });
        }
    }
}
